#2.将一个英文语句以单词为单位逆序排放到指定的文件中
from os import write

r = "this a city"
world_list = r.split() #这里将字符串按照空格分割,转成列表,才能进行逆序
print(world_list)
world_list.reverse()
r1 = " ".join(world_list) #再转成按 " " 拼接的字符串

with open(r'data/1.txt','w',encoding='utf-8',newline='') as f2:
    f2.write(r1)
    f2.flush()
